#ifndef FILE_LISTENER_H
#define FILE_LISTENER_H

#include <oatpp-websocket/oatpp-websocket/WebSocket.hpp>
#include <oatpp-websocket/oatpp-websocket/ConnectionHandler.hpp>
#include <fstream>
#include <string>

class wsFileListener : public oatpp::websocket::WebSocket::Listener
{
    private:
    static constexpr const char* TAG = "Server_WSListener";
        oatpp::data::stream::BufferOutputStream m_messageBuffer;
    public:
        void onPing(const WebSocket& socket,const oatpp::String& message) override;
        void onPong(const WebSocket& socket,const oatpp::String& message) override;
        void onClose(const WebSocket& WebSocket,v_uint16 code,const oatpp::String& message) override;
        void readMessage(const WebSocket& socket, v_uint8 opcode, p_char8 data, oatpp::v_io_size size) override;
};

class wsFileInstanceListener : public oatpp::websocket::ConnectionHandler::SocketInstanceListener
{
    private:
        static constexpr const char* TAG = "Server_WSInstanceListener";
    public:
        static std::atomic<v_int32> SOCKETS;
        void onAfterCreate(const WebSocket& socket, const std::shared_ptr<const ParameterMap>& params) override;
        void onBeforeDestroy(const WebSocket& socket) override;
};

#endif